Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Hendrik Jan 71 posts 137 karma points
    Oct 13, 2010 @ 00:07
    Hendrik Jan
    0

    Multiple word searches: "context unavailable" [fix]

    Is this package even being maintained??

    Mutliple prhase searches can give the annoying "context unavailable" text. this is a malfunction in the c# code XSLTsearch uses.

    fix:

      //bad with bug
      public int indexOfMany(string search, string[] find){
        int foundIndex = search.Length;
        foreach(string toFind in find)
          foundIndex = Math.Min(foundIndex, search.ToUpper().IndexOf(toFind.ToUpper()));
        return foundIndex;
      }
    
      //good :) no bugs
      public int indexOfMany(string search, string[] find){
        int foundIndex = search.Length;
        bool found = false;
        foreach(string toFind in find)
        {
          int res = search.ToUpper().IndexOf(toFind.ToUpper());
          if(res != -1){
            found = true;
            foundIndex = Math.Min(foundIndex, res);
          }
        }
        if(!found)return -1;
        return foundIndex;
      }
  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Nov 08, 2010 @ 16:50
    Douglas Robar
    0

    Thanks, Niels! Nice catch.

    I've just added your update to the source of the project. You'll see it in a new release of XSLTsearch soon.

    cheers,
    doug.

Please Sign in or register to post replies

Write your reply to:

Draft